﻿//-----------------------------------------------------------------------
// <copyright file="BattleSystem.cs">
//     Copyright (c) Wolf166 - BGF Framework
// </copyright>
// <Autor>Wolf166 - BGF Framework</Autor>
//-----------------------------------------------------------------------
namespace BrowserGameFramework.Units.Battle
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using BrowserGameFramework.Common;
    using BrowserGameFramework.Common.Exceptions;
    using BrowserGameFramework.Common.Logging;

    /// <summary>
    /// Handels fights between 2 armys
    /// </summary>
    public class BattleSystem
    {
        /// <summary>
        /// Computes the battle.
        /// </summary>
        /// <param name="attacker">The attacker.</param>
        /// <param name="target">The target.</param>
        public void ComputeBattle(List<Unit> attacker, Unit target)
        {
            Trace.TraceMessage("Entering BattleSystem", Enums.TraceLevel.Verbose);
            
            if (attacker.Count == 0 || target == null)
            {
                string falied = "One of the opponents has zero untits";
                Trace.TraceMessage("BGF:" + falied, Enums.TraceLevel.Error);
                throw new BGFBackendException(falied);
            }

            try
            {
                // Step:1 Army1 Attacks
                foreach (Unit unit in attacker)
                {
                    
                    
                }

                // Get all allied army to fight with all force
                List<Unit> army2 = new List<Unit>();

                // Step:2 Army2 Revenge
                foreach (Unit unit in army2)
                {

                }


                // Step:2 Army2
                //Angriffswert der Einheit
                //Verteidigungswert der Einheit
                //Einheitentyp
                //Angriffsziel
                Trace.TraceMessage("Leaving BattleSystem", Enums.TraceLevel.Verbose);
            }
            catch (Exception ex)
            {
                Trace.TraceMessage(ex.Message, Enums.TraceLevel.Error);
                throw new BGFBackendException("Internal Error", ex);
            }
        }

        /// <summary>
        /// Gets or sets the killed units army1.
        /// </summary>
        /// <value>The killed units army1.</value>
        public List<Unit> KilledUnits { get; set; }

    }
}
